package main

import "fmt"

func constructArray(n int, k int) []int {
	result := make([]int, n)
	for i := 0; i < n-k; i++ {
		result[i] = i + 1
	}
	for i := 0; n-k+2*i < n; i++ {
		result[n-k+2*i] = n - i
		if n-k+2*i+1 < n {
			result[n-k+2*i+1] = n - k + i + 1
		}
	}
	return result
}

func main() {
	fmt.Printf("%#v\n", constructArray(5, 3))
	fmt.Printf("%#v\n", constructArray(3, 1))
	fmt.Printf("%#v\n", constructArray(3, 2))
	fmt.Printf("%#v\n", constructArray(6, 2))
	fmt.Printf("%#v\n", constructArray(6, 3))
}
